using System;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Office.Interop.Outlook;

namespace Send2Sharepoint.Common
{
    public class Globals
    {
        public static string UserName{ get; set;}

        public static string Password { get; set; }

        public static string DocumentLibrary { get; set; }

        public static object ThisApplication { get; set; }

        public static object ThisInstance { get; set; }

        public static MAPIFolder Root { get; set; }

        public static string ConfigFile { get; set; }

        public static string SharepointSiteUrl { get; set; }

        public static byte[] GetFileData(string fullPath)
        {
            var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
            var reader = new BinaryReader(stream);
            var fileData = reader.ReadBytes((int)stream.Length);
            reader.Close();
            stream.Close();
            return fileData;
        }

        public static string GetDestinationUrl(string fileName)
        {
            return new Uri(new Uri(SharepointSiteUrl), DocumentLibrary + "/" + Strip(fileName)).ToString();
        }

        public static string Strip(string targetString)
        {
            return Regex.Replace(targetString, @"\W*", "");
        }
    }
}